package palf.visualEffects.timing {
import com.greensock.TimelineLite;
import com.greensock.TweenLite;

import palf.visualEffects.utils.PositionData;

internal class Delayed implements Timing {

	private var duration : Number;
	private var delay : Number;
	private var timeline : TimelineLite;

	public function Delayed(duration : Number, delay : Number) {
		this.duration = duration;
		this.delay = delay;
	}

	public function apply(data : PositionData) : void {
		if (!timeline) {
			timeline = new TimelineLite({ onComplete: resetTimeline });
		}
		var tween : TweenLite = TweenLite.to(data.target, duration, {
			x : data.x,
			y : data.y,
			alpha : data.alpha,
			rotation : data.rotation
		});
		timeline.append(tween, delay - duration);
	}

	private function resetTimeline() : void {
		timeline = null;
	}

	public function reset() : void {

	}

}
}
